package com.example.blueconn.utils;

import android.content.Context;
import android.content.DialogInterface;

import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
import com.qmuiteam.qmui.widget.dialog.QMUITipDialog;

/**
 * Created by zhudongao
 * Desc
 * Date 2020/7/23
 */

public class DialogUtils {

    public static void showTipDialog(Context context, int iconType, String info) {
        final QMUITipDialog tipDialog = new QMUITipDialog.Builder(context)
                .setIconType(iconType)
                .setTipWord(info)
                .create();
        tipDialog.show();
        ThreadPoolUtils.runOnUiThreadDelay(tipDialog::dismiss, 1500);
    }

    public static void confirmDialog(Context context, String title, String msg,
                                     QMUIDialogAction.ActionListener cancelListener, QMUIDialogAction.ActionListener confirmListener) {
        new QMUIDialog.MessageDialogBuilder(context)
                .setTitle(title)
                .setMessage(msg)
                .addAction("取消", cancelListener)
                .addAction("确认", confirmListener)
                .create().show();
    }

    public static void showSingleSelectDialog(Context context, String[] items, DialogInterface.OnClickListener listener) {
        new QMUIDialog.CheckableDialogBuilder(context).
                setCheckedIndex(0)
                .addItems(items, listener)
                .create().show();

    }
}
